package com.hzeport.bgs22emduty.util;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.hzeport.bgs22emduty.vo.dutyScheduleInfo.DutyScheduleInfoMoneyExcelVO;
import com.hzeport.bgs22emduty.vo.dutydignInfo.DutyScheduleExcleVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.VerticalAlignment;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Slf4j
public class ExcelUtil {
    private static String FILE_PATH="test.xlsx";

    public static void exportGoods(List<DutyScheduleExcleVO> wxpParamDictionaryExcelVOS, String fileName) {
        EasyExcel.write(fileName,DutyScheduleExcleVO.class).sheet().doWrite(wxpParamDictionaryExcelVOS);
    }

    public static void exportMoneys(List<DutyScheduleInfoMoneyExcelVO> dutyScheduleInfoMoneyExcelVOS, String fileName) {
        WriteCellStyle writeCellStyle = new WriteCellStyle();
        writeCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(null,writeCellStyle);
        int[] index={9};
        Set<String> exclude=new HashSet<String>();
        exclude.add("dUsernameDelete");
        EasyExcel.write(fileName,DutyScheduleInfoMoneyExcelVO.class)
                .autoCloseStream(Boolean.TRUE)
                .registerWriteHandler(new ExcelFillCellMergeStrategy(1, index))
                .registerWriteHandler(horizontalCellStyleStrategy)
                .sheet().doWrite(dutyScheduleInfoMoneyExcelVOS);
    }
}
